<template>
  <vue-office-pdf :src="params.url" @rendered="renderedHandler" @error="errorHandler" />
</template>

<script lang="ts" setup>
import { onMounted } from 'vue';
import { showLoading, hideLoading, getCurrentInstance, showToast } from '@tarojs/taro';
//引入VueOfficePdf组件
import VueOfficePdf from '@vue-office/pdf';
/**
 * @description 当前路由信息
 */
const params = getCurrentInstance().router?.params as {
  url: string;
};

onMounted(() => {
  showLoading();
});

function renderedHandler() {
  console.log('渲染完成');
  hideLoading();
}
function errorHandler() {
  console.log('渲染失败');
  hideLoading();
  showToast({ title: '文件解析失败', icon: 'error' });
}
</script>
